package com.stu.spring.context.chapter06.finishbf;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class String2DateConverter implements Converter<String, Date> {
	private SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

	@Override
	public Date convert(String source) {
		try {
			return SDF.parse(source);
		} catch (ParseException e) {
			System.out.println("convert exception");
			return null;
		}
	}
}
